import { t } from '@/locales/i18n';

import {
  FlowNodeInputTypeEnum,
  FlowNodeOutputTypeEnum,
  FlowNodeTemplateTypeEnum,
  FlowNodeTypeEnum,
  NodeInputKeyEnum,
  NodeOutputKeyEnum,
  WorkflowIOValueTypeEnum,
} from '../../constant';
import { FlowNodeTemplateType } from '../../node';
import { Input_Template_DynamicInput } from '../input';
import { Output_Template_AddOutput } from '../outup';
import { getHandleConfig } from '../utils';

export const nodeLafCustomInputConfig = {
  selectValueTypeList: Object.values(WorkflowIOValueTypeEnum),
  showDescription: false,
  showDefaultValue: true,
};

export const LafModule: FlowNodeTemplateType = {
  id: FlowNodeTypeEnum.lafModule,
  templateType: FlowNodeTemplateTypeEnum.other,
  flowNodeType: FlowNodeTypeEnum.lafModule,
  sourceHandle: getHandleConfig(true, true, true, true),
  targetHandle: getHandleConfig(true, true, true, true),
  avatar: 'lafDispatch',
  name: t('workflow:laf_function_call_test'),
  intro: t('workflow:intro_laf_function_call'),
  showStatus: true,
  isTool: true,
  courseUrl: '/docs/workflow/modules/laf/',
  version: '481',
  isFolded: true,
  inputs: [
    {
      ...Input_Template_DynamicInput,
      description: t('workflow:dynamic_input_description'),
      customInputConfig: nodeLafCustomInputConfig,
    },
    {
      key: NodeInputKeyEnum.httpReqUrl,
      renderTypeList: [FlowNodeInputTypeEnum.hidden],
      valueType: WorkflowIOValueTypeEnum.string,
      label: '',
      description: 'core.module.input.description.Http Request Url',
      placeholder: 'https://api.ai.com/getInventory',
      required: false,
    },
  ],
  outputs: [
    {
      id: NodeOutputKeyEnum.httpRawResponse,
      key: NodeOutputKeyEnum.httpRawResponse,
      label: t('workflow:raw_response'),
      description: t('workflow:http_raw_response_description'),
      valueType: WorkflowIOValueTypeEnum.any,
      type: FlowNodeOutputTypeEnum.static,
    },
    {
      ...Output_Template_AddOutput,
    },
  ],
};
